<!--
 * @Descripttion: 
 * @Version: 
 * @Author: gaohj
 * @Date: 2023-01-12 14:34:03
 * @LastEditors: Please set LastEditors
 * @LastEditTime: 2023-01-12 14:39:44
-->
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <input type="text">
    <button>点击切换</button>

    <script>
        // 获取 input 标签 
            // 为了拿到标签的属性的值 
            // 如果是text 赋值 password
            // 如果是password 赋值 text
        // 获取 button 标签
        var inputEle = document.querySelector('input');
        var btn = document.querySelector('button');

        btn.onclick = function(){
            // alert('别碰我');
            var type = inputEle.type;
            if(type == 'text'){
                inputEle.type = 'password';
            }
            else{
                inputEle.type = 'text';
            }
        }
    </script>
</body>
</html>